package cn.szzsi.common.kit;

import com.alibaba.fastjson.JSONObject;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class SendSMSUtil {
	public static String sn = "8SDK-EMY-6699-SCRQN";// 软件序列号,请通过亿美销售人员获取
    public static String key = "123456";// 序列号首次激活时自己设定
    public static String password = "630451";// 密码,请通过亿美销售人员获取
    public static String baseUrl = "https://hprpt2.eucp.b2m.cn:8080/sdkproxy/";
	public static String  sendSMS(String phone,String message) throws UnsupportedEncodingException{
		message = URLEncoder.encode(message, "UTF-8");
		long seqId = System.currentTimeMillis();
		String code="";
		String param = "cdkey=" + sn + "&password=" + key + "&phone=" + phone + "&message=" + message + "&addserial=" + code+ "&seqid=" + seqId;
		String url  = baseUrl + "sendsms.action";
		String ret = SDKHttpClient.sendSMS(url, param);
		System.out.println(JSONObject.toJSON(ret));
		return ret;
	}

	public static String  sendActivitySMS(String phone,String message) throws UnsupportedEncodingException{
		message = URLEncoder.encode(message, "UTF-8");
		long seqId = System.currentTimeMillis();
		String code="";
		String param = "cdkey=6SDK-EMY-6666-SBZPT&password=254430&phone=" + phone + "&message=" + message + "&addserial=" + code+ "&seqid=" + seqId;
		String url  = "https://sdktaows.eucp.b2m.cn:8080/SMSsendsms.action";
		String ret = SDKHttpClient.sendSMS(url, param);
		System.out.println(JSONObject.toJSON(ret));
		return ret;
	}

	public static void main(String[] args) throws UnsupportedEncodingException {
//		sendActivitySMS("18862313312","【微米荟商城】恭喜您成功领取卡券，券码：XXXXXX，有效期至2017年8月31日，节假日通用。预约咨询 4006217661");
		sendSMS("18862313312","【微米荟商城】你领取的券码为：12345678，谢谢您的参与");
	}

}
